
package cz.czu.pef.DataModelling.tests.data;


import java.util.logging.*;

import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import cz.czu.pef.DataModelling.domainObjects.MachineType;
import cz.czu.pef.DataModelling.tests.utils.SpringLoaderHelper;

@Component(value="fillBasicData")
@Transactional
public class FillBasicData extends BasicDataExt
{
  private static final Logger logger = Logger.getLogger(FillBasicData.class.getName());

  public static void main(String[] args)
  {
    BasicDataExt basicData = (BasicDataExt)SpringLoaderHelper.getApplicationContext().getBean("fillBasicData");
    basicData.performDataOperation();
  }

  @Override
  public void performDataOperation()
  {
    try
    {
      logger.log(Level.INFO, "performDataOperation():: Entry");

      prepareSharedData.fillBasicData();
      prepareGardeningData.fillBasicData();
      prepareITData.fillBasicData();

      prepareGardeningData.fillPeopleAndCompanies();
      prepareITData.fillPeopleAndCompanies();

      MachineType[] types = prepareGardeningData.fillMachineries();
      prepareGardeningData.fillRandomMachinery(types);

      prepareSharedData.fillRandomTrainings();
    }
    finally
    {
      logger.log(Level.INFO, "performDataOperation():: Exit");
    }
  }
}
